package org.ume.school.modules.home;

import org.ume.school.crawl.CrawlRobot;
import de.nava.informa.core.ParseException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * Created by Django on 2017/7/15.
 */
@RestController
@RequestMapping("/v0.1/home")
public class HomeController {

    @Resource
    CrawlRobot mCrawlRobot;

    @RequestMapping(value = "/index", produces = "application/json")
    public Model getList() {
        Model model = new Model();
        model.setCode("hangyx");
        model.setMessage("kkkk");
        return model;
    }

    @RequestMapping(value = "/crawlrss")
    public void crawlRss(@RequestParam(value = "rss", required = true) String rss,
                         @RequestParam(value = "type", required = true) String type) throws IOException, ParseException {
//        mCrawlRobot.rss("http://www.eduxiao.com/data/rss/1.xml", "小学生作文");
        mCrawlRobot.rss(rss, type);
    }


}
